package cn.yi.fast.mq.rocketmq.message.handler;

import cn.yi.fast.mq.rocketmq.coder.MessageDecoder;
import cn.yi.fast.mq.rocketmq.coder.MessageEncoder;
import com.alibaba.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext;
import com.alibaba.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
import com.alibaba.rocketmq.common.message.MessageExt;

import javax.annotation.Resource;
import java.util.Map;

public abstract class AbstractMessageHandler implements MessageHandler<Map<String, Object>> {

    @Resource(name = "messageDecoder")
    private MessageDecoder<Map<String, Object>> messageDecoder;
    @Resource(name = "messageEncoder")
    private MessageEncoder<Map<String,Object>> messageEncoder;
    public abstract ConsumeConcurrentlyStatus process0(Map<String, Object> data, MessageExt msg, ConsumeConcurrentlyContext context);

    public ConsumeConcurrentlyStatus process(Map<String, Object> data, MessageExt msg, ConsumeConcurrentlyContext context) {
        //前置处理
        return process0(data,msg,context);
    }

    public MessageDecoder<Map<String, Object>> getMessageDecoder() {
        return messageDecoder;
    }
}
